package com.zby.scms.service.impl;

import com.zby.scms.entity.Competition;
import com.zby.scms.dao.CompetitionDao;
import com.zby.scms.service.CompetitionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 竞赛项目competition(Competition)表服务实现类
 *
 * @author zhangboyi
 * @since 2020-01-14 12:14:28
 */
@Service("competitionService")
public class CompetitionServiceImpl implements CompetitionService {
    @Resource
    private CompetitionDao competitionDao;

    /**
     * 通过ID查询单条数据
     *
     * @param competeid 主键
     * @return 实例对象
     */
    @Override
    public Competition queryById(Integer competeid) {
        return this.competitionDao.queryById(competeid);
    }

    /**
     * 查询多条数据
     *
     * @param competition 实体对象

     * @return 对象列表
     */
    @Override
    public List<Competition> queryAll(Competition competition) {
        return this.competitionDao.queryAll(competition);
    }

    /**
     * 新增数据
     *
     * @param competition 实例对象
     * @return 实例对象
     */
    @Override
    public Competition addCompetition(Competition competition) {
        this.competitionDao.addCompetition(competition);
        return competition;
    }

    /**
     * 修改数据
     *
     * @param competition 实例对象
     * @return 实例对象
     */
    @Override
    public Competition updateCompetition(Competition competition) {
        this.competitionDao.updateCompetition(competition);
        return this.queryById(competition.getCompeteid());
    }

    /**
     * 通过主键删除数据
     *
     * @param competeid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer competeid) {
        return this.competitionDao.deleteById(competeid) > 0;
    }
}